 use "EDTG_Data.dta"

 set more off
 
 
replace gname="Islamic State of Iraq and the Levant (ISIL)" if gname=="Al-Qaida in Iraq"
replace gname="Islamic State of Iraq and the Levant (ISIL)" if gname=="Islamic State of Iraq (ISI)"
replace gname="Jundallah (Iran)" if gname=="Jundallah (Pakistan)"


drop base EAP ECA LAC NA SAS SSA peak_size total_injuries nonterr_deaths nonterr_injuries terr_casualties nonterr_casualties terr_deaths terr_injuries

sort gid left
by gid (left), sort: gen diffleft = left[1] != left[_N]
list gid left if diffleft

sort gid nat
by gid (nat), sort: gen diffnat = nat[1] != nat[_N]
list gid nat if diffnat

sort gid rel
by gid (rel), sort: gen diffrel = rel[1] != rel[_N]
list gid rel if diffrel

sort gid right
by gid (right), sort: gen diffright = right[1] != right[_N]
list gid right if diffright

sort gid ercsr
by gid (ercsr), sort: gen differcsr = ercsr[1] != ercsr[_N]
list gid ercsr if differcsr

sort gid pch
by gid (pch), sort: gen diffpch = pch[1] != pch[_N]
list gid pch if diffpch

sort gid sq
by gid (sq), sort: gen diffsq = sq[1] != sq[_N]
list gid sq if diffsq

sort gid tch
by gid (tch), sort: gen difftch = tch[1] != tch[_N]
list gid tch if difftch


***prev establishes no variation within groups over years on these variables




gen gnumb=.

replace gnumb=1 if gname=="Abdullah Azzam Brigades"
replace gnumb=2 if gname=="Abu Nidal Organization (ANO)"
replace gnumb=3 if gname=="Abu Sayyaf Group (ASG)"
 
replace gnumb=4 if gname=="al-Qaeda"
replace gnumb=5 if gname=="Al-Qaida in the Indian Subcontinent"
replace gnumb=6 if gname=="Al-Aqsa Martyrs Brigade"
replace gnumb=7 if gname=="Al-Nusrah Front"
replace gnumb=8 if gname=="Al-Shabaab"

replace gnumb=9 if gname=="Ansar al-Dine"
*replace gnumb=9 if gname=="Ansar al-Dine (Mali)"

replace gnumb=10 if gname=="Ansar al-Islam"
replace gnumb=11 if gname=="Ansar al-Sharia (Libya)"
replace gnumb=12 if gname=="Ansar al-Sharia (Tunisia)"
replace gnumb=13 if gname=="Ansaru (Jama'atu Ansarul Muslimina Fi Biladis Sudan)"
replace gnumb=14 if gname=="Al-Qaida in the Arabian Peninsula (AQAP)"

replace gnumb=15 if gname=="Al-Qaida in the Islamic Maghreb (AQIM)"
*replace gnumb=15 if gname=="Salafist Group for Preaching and Fighting (GSPC)"
replace gnumb=16 if gname=="Armed Islamic Group (GIA)"
replace gnumb=17 if gname=="Army of Islam"
replace gnumb=18 if gname=="Asbat al-Ansar"

replace gnumb=19 if gname=="Aum ShinriKyo"
replace gnumb=20 if gname=="Basque Fatherland and Freedom (ETA)"
replace gnumb=21 if gname=="Boko Haram"
replace gnumb=22 if gname=="Continuity Irish Republican Army (CIRA)"
replace gnumb=23 if gname=="New People's Army (NPA)"
 
replace gnumb=24 if gname=="Democratic Front for the Liberation of Palestine"
replace gnumb=25 if gname=="Revolutionary Armed Forces of Colombia (FARC)"

replace gnumb=26 if gname=="al-Gama'at al-Islamiyya (IG)"
 
replace gnumb=27 if gname=="Hamas"
replace gnumb=28 if gname=="Haqqani Network"
replace gnumb=29 if gname=="Harkatul Jihad-e-Islami"
 
replace gnumb=30 if gname=="Harkat ul-Mujahedin"
 
replace gnumb=31 if gname=="Hezbollah Palestine"
replace gnumb=32 if gname=="Indian Mujahideen"

*replace gnumb=33 if gname=="Al-Qaida in Iraq"
replace gnumb=33 if gname=="Islamic State of Iraq and the Levant (ISIL)"
*replace gnumb=33 if gname=="Islamic State of Iraq (ISI)"
replace gnumb=34 if gname=="Ansar Bayt al-Maqdis (Ansar Jerusalem)"
replace gnumb=35 if gname=="Khorasan Chapter of the Islamic State"
*******
replace gnumb=36 if gname=="Hizbul Mujahideen (HM)"
********
replace gnumb=37 if gname=="Islamic Jihad Union (Uzbekistan)"

replace gnumb=38 if gname=="Islamic Movement of Uzbekistan"
replace gnumb=39 if gname=="Jaish-e-Mohammad (JeM)"
replace gnumb=40 if gname=="Japanese Red Army (JRA)"
replace gnumb=41 if gname=="Jamaah Ansharut Tauhid (JAT)"
replace gnumb=42 if gname=="Jemaah Islamiya (JI)"

replace gnumb=43 if gname=="Jundallah (Iran)"
*be sure to check other aliases
*replace gnumb=43 if gname=="Jundallah (Pakistan)"
replace gnumb=44 if gname=="Kahane Chai"
replace gnumb=45 if gname=="Khmer Rouge"

replace gnumb=46 if gname=="Kurdistan Workers Party(PKK)"
replace gnumb=47 if gname=="Lashkar-e-Jhangvi"
replace gnumb=48 if gname=="Lashkar-e-Taiba (LeT)"
replace gnumb=49 if gname=="Liberation Tigers of Tamil Eelam (LTTE)"
replace gnumb=50 if gname=="Manuel Rodriguez Patriotic Front (FPMR)"

replace gnumb=51 if gname=="Mujahideen-I-Khalq"
replace gnumb=52 if gname=="Mujahedeen Shura Council in the Environs of Jerusalem"
replace gnumb=53 if gname=="National Liberation Army of Colombia (ELN)"
replace gnumb=54 if gname=="Palestine Liberation Front (PLF)"
replace gnumb=55 if gname=="Palestinian Islamic Jihad (PIJ)"
replace gnumb=56 if gname=="Popular Front for the Liberation of Palestine (PFLP)"


replace gnumb=57 if gname=="Popular Front for the Liberation of Palestine-General Command (PFLP-GC)"
replace gnumb=58 if gname=="Real Irish Republican Army (RIRA)"
replace gnumb=59 if gname=="Revolutionary Nuclei"
replace gnumb=60 if gname=="November 17 Revolutionary Organization (N17RO)"
replace gnumb=61 if gname=="Devrimici Halk Kurtulus Cephesi (DHKP/C)"
replace gnumb=62 if gname=="Revolutionary Struggle"

replace gnumb=63 if gname=="Shining Path"

replace gnumb=64 if gname=="Tehrik-i-Taliban Pakistan(TTP)"
replace gnumb=65 if gname=="Tupac Amaru Revolutionary Movement (MRTA)"

replace gnumb=66 if gname=="United Self Defense Forces of Colombia (AUC)"
***
replace gnumb=67 if gname== "Libya Shield Force"
replace gnumb=68 if gname=="Kata'ib Hezbollah"

gen fto=1
replace fto=0 if gnumb==.







